home *** CD-ROM | disk | FTP | other *** search
- // Dynamic link library implementation of NeuroSolutions WinnerTakeAllAxon component
-
- #include "NSDLL.h"
-
- /************************************************/
- /* Macro to access the PE layer in matrix form */
-
- #define data(i,j) data[j+i*cols]
-
- /***********************************/
- /* Forward activation of component */
-
- __declspec(dllexport) void performAxon(
- DLLData *instance, // Pointer to instance data (may be NULL)
- NSFloat *data, // Pointer to the layer of processing elements (PEs)
- int rows, // Number of rows of PEs in the layer
- int cols // Number of columns of PEs in the layer
- )
- {
- register int i, length=rows*cols, winner=0;
-
- for (i=1; i<length; i++)
- if (data[i] > data[winner])
- winner = i;
- for (i=0; i<length; i++)
- data[i] = (NSFloat)0.0;
- data[winner] = (NSFloat)1.0;
- }
-
- /******************************************/
- /* Management of instance data (OPTIONAL) */
- /*
- __declspec(dllexport) DLLData *allocAxon(
- DLLData *oldInstance, // Pointer to the last instance if reallocating
- int rows, // Number of rows of PEs in the layer
- int cols // Number of columns of PEs in the layer
- )
- {
- DLLData *instance = allocDLLInstance(oldInstance);
- return instance;
- }
-
- __declspec(dllexport) void freeAxon(DLLData *instance)
- {
- freeDLLInstance(instance);
- }
- */